package com.tianyang.yukuaifu.business.auth.provider;

import android.content.Context;
import android.content.Intent;

import com.tianyang.yukuaifu.business.auth.contract.AuthConfig;
import com.tianyang.yukuaifu.business.auth.view.AuthCompanyActivity;
import com.tianyang.yukuaifu.business.auth.view.AuthIndividualActivity;
import com.tianyang.yukuaifu.business.auth.view.AuthMerchantActivity;
import com.tianyang.yukuaifu.business.auth.view.AuthSelectTypeActivity;
import com.tianyang.yukuaifu.business.auth.view.AuthServiceActivity;
import com.tianyang.yukuaifu.business.auth.view.BusinessInfoActivity;
import com.tianyang.yukuaifu.business.auth.view.MerchantEmpowerActivity;
import com.tianyang.yukuaifu.business.auth.view.MerchantInfoManageActivity;
import com.tianyang.yukuaifu.utils.IntentTool;

/**
 * Description：实名模块跳转
 * Created by 薛勇军 on 2024/1/9.
 */
public class AuthOpenProvider {

    private static AuthOpenProvider instance;

    public static AuthOpenProvider getInstance() {
        if (instance == null) {
            synchronized (AuthOpenProvider.class) {
                if (instance == null) {
                    instance = new AuthOpenProvider();
                }
            }
        }
        return instance;
    }

    /**
     * 商户进件选择类型
     */
    public void openAuthSelectTypeActivity(Context context, boolean isMine) {
        Intent intent = new Intent(context, AuthSelectTypeActivity.class);
        intent.putExtra(AuthConfig.INTENT_IS_MINE, isMine);
        IntentTool.startActivity(context, intent);
    }

    /**
     * 商户信息管理
     */
    public void openMerchantInfoManageActivity(Context context) {
        IntentTool.startActivity(context, MerchantInfoManageActivity.class);
    }

    /**
     * 授权
     */
    public void openMerchantEmpowerActivity(Context context, String userName) {
        Intent intent = new Intent(context, MerchantEmpowerActivity.class);
        intent.putExtra(AuthConfig.INTENT_USERNAME, userName);
        IntentTool.startActivity(context, intent);
    }

    public void openAuthByMchType(Context context, int mchType, String posStatus, boolean isOnlyRead, String userName) {
        if (mchType == 0) {
            openAuthCompanyActivity(context, userName, posStatus, isOnlyRead, false);
        } else if (mchType == 1) {
            openAuthMerchantActivity(context, userName, posStatus, isOnlyRead, false);
        } else if (mchType == 2) {
            openAuthIndividualActivity(context, userName, posStatus, isOnlyRead, false);
        }
    }

    public void openAuthByMchType(Context context, int mchType, String posStatus, boolean isOnlyRead, String userName, boolean isAgent) {
        if (mchType == 0) {
            openAuthCompanyActivity(context, userName, posStatus, isOnlyRead, isAgent, false);
        } else if (mchType == 1) {
            openAuthMerchantActivity(context, userName, posStatus, isOnlyRead, isAgent, false);
        } else if (mchType == 2) {
            openAuthIndividualActivity(context, userName, posStatus, isOnlyRead, isAgent, false);
        }
    }

    /**
     * 企业商户进件
     */
    public void openAuthCompanyActivity(Context context, String userName, String posStatus, boolean isOnlyRead, boolean isFinish) {
        Intent intent = new Intent(context, AuthCompanyActivity.class);
        intent.putExtra(AuthConfig.INTENT_USERNAME, userName);
        intent.putExtra(AuthConfig.INTENT_POS_STATUS, posStatus);
        intent.putExtra(AuthConfig.INTENT_ONLY_READ, isOnlyRead);
        IntentTool.startActivity(context, intent, isFinish);
    }

    public void openAuthCompanyActivity(Context context, String userName, String posStatus, boolean isOnlyRead, boolean isAgent, boolean isFinish) {
        Intent intent = new Intent(context, AuthCompanyActivity.class);
        intent.putExtra(AuthConfig.INTENT_USERNAME, userName);
        intent.putExtra(AuthConfig.INTENT_POS_STATUS, posStatus);
        intent.putExtra(AuthConfig.INTENT_ONLY_READ, isOnlyRead);
        intent.putExtra(AuthConfig.INTENT_IS_AGENT, isAgent);
        IntentTool.startActivity(context, intent, isFinish);
    }

    /**
     * 小微商户进件
     */
    public void openAuthMerchantActivity(Context context, String userName, String posStatus, boolean isOnlyRead, boolean isFinish) {
        Intent intent = new Intent(context, AuthMerchantActivity.class);
        intent.putExtra(AuthConfig.INTENT_USERNAME, userName);
        intent.putExtra(AuthConfig.INTENT_POS_STATUS, posStatus);
        intent.putExtra(AuthConfig.INTENT_ONLY_READ, isOnlyRead);
        IntentTool.startActivity(context, intent, isFinish);
    }

    public void openAuthMerchantActivity(Context context, String userName, String posStatus, boolean isOnlyRead, boolean isAgent, boolean isFinish) {
        Intent intent = new Intent(context, AuthMerchantActivity.class);
        intent.putExtra(AuthConfig.INTENT_USERNAME, userName);
        intent.putExtra(AuthConfig.INTENT_POS_STATUS, posStatus);
        intent.putExtra(AuthConfig.INTENT_ONLY_READ, isOnlyRead);
        intent.putExtra(AuthConfig.INTENT_IS_AGENT, isAgent);
        IntentTool.startActivity(context, intent, isFinish);
    }

    /**
     * 个体工商户
     */
    public void openAuthIndividualActivity(Context context, String userName, String posStatus, boolean isOnlyRead, boolean isFinish) {
        Intent intent = new Intent(context, AuthIndividualActivity.class);
        intent.putExtra(AuthConfig.INTENT_USERNAME, userName);
        intent.putExtra(AuthConfig.INTENT_POS_STATUS, posStatus);
        intent.putExtra(AuthConfig.INTENT_ONLY_READ, isOnlyRead);
        IntentTool.startActivity(context, intent, isFinish);
    }

    public void openAuthIndividualActivity(Context context, String userName, String posStatus, boolean isOnlyRead, boolean isAgent, boolean isFinish) {
        Intent intent = new Intent(context, AuthIndividualActivity.class);
        intent.putExtra(AuthConfig.INTENT_USERNAME, userName);
        intent.putExtra(AuthConfig.INTENT_POS_STATUS, posStatus);
        intent.putExtra(AuthConfig.INTENT_ONLY_READ, isOnlyRead);
        intent.putExtra(AuthConfig.INTENT_IS_AGENT, isAgent);
        IntentTool.startActivity(context, intent, isFinish);
    }

    /**
     * 行业类别
     */
    public void openBusinessInfoActivity(Context context, String merchantType, String mccType, String channel, int requestCode) {
        Intent intent = new Intent(context, BusinessInfoActivity.class);
        intent.putExtra(AuthConfig.INTENT_MERCHANT_TYPE, merchantType);
        intent.putExtra(AuthConfig.INTENT_MCC_TYPE, mccType);
        intent.putExtra(AuthConfig.INTENT_CHANNEL, channel);
        IntentTool.startActivityForResult(context, intent, requestCode);
    }

    /**
     * 服务商认证
     */
    public void openAuthServiceActivity(Context context) {
        IntentTool.startActivity(context, AuthServiceActivity.class);
    }
}
